<template>
  <BaseForm v-model="formDataModel" @close="$emit('callBack')" />
</template>

<script lang="tsx" setup>
import type { FormInstance } from 'element-plus'
import FORM_FIELD_TYPE from "/@/constants/FormFieldType.ts";
import StoreInfoApi from '~/src/api/webPath/StoreInfoApi';
import StoreInfoDetailApi from '/@/api/webPath/StoreInfoDetailApi.ts';
defineOptions({
  name: 'SupplierInfoEdit',
})
const props = defineProps({
  modelValue: {
  }
})
const emit = defineEmits(['fetch-data', 'callBack'])
const exportXlsName = ref()
const formRef = ref<FormInstance>();
const title = ref<string>('');
const dialogFormVisible = ref<boolean>(false);
const supplierList = ref()
const storeList = ref()
onMounted(async () => {
  // TODO 更换为全量获取仓库列表
  const data = (await StoreInfoApi.getPageData({})).data
  console.log("data:", data)
  storeList.value = data.records.map(item => ({ label: item.storeName, value: item.storeName }))
  console.log("supplierTypeList", storeList.value)

})

const licenseType = ref()

const formDataModel = ref({
  columnCount: 1,
  expandLimit: 6,
  autoFit: false,
  columnWidth: '300px',
  labelPosition: 'right',
  labelWidth: '100px',
  modelData: {},

  callback: (result) => {
    emit('callBack', result); // MODIFIED: 传递整个表单数据
  },
  items: [  //表单item数据初始化

    {
      label: "仓库类型",
      field: "supplierType",
      fixed: true,
      clearable: true,
      type: FORM_FIELD_TYPE.SINGLE_LAYER_SELECT,
      options: storeList,
      placeholder: "请输入",



      rule: [{
        trigger: 'blur',
        validator: (rule: any, value: any, callback: any) => {  //绑定验证
          callback();
        },
      },
      {
        required: true,
        message: "请选择仓库类型"
      }
      ],
    },

  ],

})

//方法暴露区域  todo
defineExpose({

})

</script>
